package com.sm.controller;

import com.sm.entity.ResultMap;
import com.sm.entity.Role;
import com.sm.service.UserRoleService;
import jdk.internal.org.objectweb.asm.Handle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;

@RequestMapping("/admin")
@Controller
public class RoleController {
    @Autowired
    UserRoleService userRoleService;
    @Autowired
    ResultMap resultMap;

    @RequestMapping("/hello")
    @ResponseBody
    public String  hello(){
        return "1111";
    }

//    @RequestMapping("")
//    public List<Role> roleByUid(Integer uid){
//
//    }
    @ResponseBody
    @RequestMapping("/role/roleall")
    public ResultMap roleAll(@RequestParam(required = true) Integer uid) throws Exception {
        List<Role> allRole = userRoleService.findAllRole();
        List<Role> userRole = userRoleService.findUserRole(uid);
        resultMap.setResult("roles",allRole);
        resultMap.setResult("useroles",userRole);
        return resultMap;
    }
}
